package com.xyy.saas.payment.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.xyy.elasticjob.client.annotation.ElasticJobConf;
import com.xyy.saas.payment.manage.cores.enums.BusinessOrderTypeEnum;
import com.xyy.saas.payment.service.job.OrderJobService;
import com.xyy.saas.payment.util.DateUtil;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

@ElasticJobConf(name = "xyy.elastic.job.manage.FrozenSettlementGenerateJob", cron = "0 30 1 * * ?")
@Slf4j
public class FrozenSettlementGenerateJob implements SimpleJob {
    @Resource
    private OrderJobService orderJobService;

    @Override
    public void execute(ShardingContext shardingContext) {
        try {
            long startTime = System.currentTimeMillis();
            log.info("[xyy.elastic.job.FrozenSettlementGenerateJob] start.");
            orderJobService.genFrozenSettlementOrder(BusinessOrderTypeEnum.EC_POP.getType(),
                    DateUtil.getDay(-1), DateUtil.getDay(0));
            log.info("[xyy.elastic.job.FrozenSettlementGenerateJob] end. cost=" + (System.currentTimeMillis() - startTime));
        }
        catch(Exception ex) {
            log.error("FrozenSettlementGenerateJob error=" + ex.getMessage() ,ex);
        }
    }
}